package com.wawayaya.bookreader.bean;

import android.graphics.Point;

/**
 * Created by wang_qian on 2015/7/9.
 */
public class RectSerialBoolean implements java.io.Serializable {
    private static final long serialVersionUID = 1L;

    public int left = 0;
    public int top = 0;
    public int right = 0;
    public int bottom = 0;
    public boolean newBlockStart = false;

    public RectSerialBoolean(){
    }

    public RectSerialBoolean(int ileft, int itop, int iright, int ibottom, boolean newstart){
        left = ileft;
        top = itop;
        right = iright;
        bottom = ibottom;
        newBlockStart = newstart;
    }

    public RectSerialBoolean(RectSerialBoolean obj){
        if(null != obj) {
            left = obj.left;
            top = obj.top;
            right = obj.right;
            bottom = obj.bottom;
            newBlockStart = obj.newBlockStart;
        }
    }


    public void doratio(float fratio) {
        left = (int)(left * fratio + 0.5);
        top = (int)(top * fratio + 0.5);
        right = (int)(right * fratio + 0.5);
        bottom = (int)(bottom * fratio + 0.5);
    }

    public boolean largerthan(RectSerial rs) {
        if(null == rs) {
            return true;
        }
        return (top > rs.top || bottom > rs.bottom);
    }

    public boolean lessthan(RectSerial rs) {
        return !largerthan(rs);
    }
    public boolean includePt(Point pt) {
        if (pt.x > left && pt.x < right && pt.y > top && pt.y < bottom) {
            return true;
        }
        return false;
    }
}
